package com.itcoon.cloud.framework.ex.config;

import com.itcoon.cloud.framework.enums.CommonResponseCode;
import com.itcoon.cloud.framework.ex.errorcode.CommonServiceErrorCode;
import com.itcoon.cloud.framework.ex.register.IErrorCodeRegister;
import com.itcoon.cloud.framework.utils.SpringUtils;
import org.springframework.boot.autoconfigure.AutoConfiguration;

@AutoConfiguration
public class ExRegistryConfiguration implements ExRegistryConfigurer {

    @Override
    public void registerErrorCodes(IErrorCodeRegister register) {
        CommonResponseCode[] commonResponseCodes =  CommonResponseCode.values();
        for (CommonResponseCode commonResponseCode : commonResponseCodes) {
            register.register(SpringUtils.getApplicationName(), commonResponseCode.getCode(), commonResponseCode.getMessage());
        }
        register.register(SpringUtils.getApplicationName(), CommonServiceErrorCode.class);
    }
}
